extends site

block append head 
  link(rel='stylesheet', href='stylesheets/catalog.css')

block main-stage
  .main-stage-inner 
    .page-header
      h1 
        | #{title} 
        small= description

  .catalog-stage
    mixin displayPost(post)
      .date-box
        .date= post.date.getDate()
        .year-month= post.date.getFullYear()+' / '+(post.date.getMonth()+1)
      .box
        .title
          a(href='article/'+post.url)= post.title
        .description !{post.html}
        .tags
          each t in post.tag
            span.tag: a(href='articles/?tag=')= '#'+t
      .clearfix

    .articles
      - var ppost = {author:{}}
      - var position = false
      each post in posts
        if ppost.author.name != post.author.name
          - position = !position

        if position
          .post.post-left
            mixin displayPost(post)
        else 
          .post.post-right
            mixin displayPost(post)

        - ppost = post
      else
        .alert.alert-info.no-result No articles yet.

      .pagination.pagination-centered
        ul
          li: a(href='?page='+(page-1)): &laquo;
          - for(var i=1; i<=pages; i++)
            li: a(href='?page='+i)= i
          li: a(href='?page='+(page+1)): &raquo;


    .sidebar
      .sidebar-box.search-box
        .title 搜索
        .content
          form(action='articles/', method='GET')
            .input-append
              input(type='text',name='tag',placeholder='发现有趣的东西~').span2
              button(type='submit').btn.btn-primary 搜索

